a={'zero': 0, 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9}
try:
    n=input()
    b=n.split(" ")
    m=""
    c=[]
    for i in b:
        c.append(str(a[i]))
    z="".join(c)
    def pip(n):
        if not n%2:
            return n==2
        d=3
        while d*d <= n and n%d:
            d+=2
        return d*d>n
    num = int(z)
    tmp = abs(num-2)
    res = 2
    k = 3
    while True:
        if pip(k):
            t = abs(num - k)
            if t<tmp:
                tmp=t
                res=k
            else:
                print(res)
                break
        k+=2
except Exception:
    print("Wrong input")
